//
// Created by andrew on 2024/9/24.
//


#include <string>
#include <vector>
#include <unordered_set>

#include <iostream>
#include <gtest/gtest.h>
#include <climits>

using namespace std;


class Solution {
public:
    bool isPalindrome(int x) {
        // 特殊情况: 1. x < 0不是回文数 2. 最后一位为0但是x不是0的情况也不符合
        if (x < 0 || (x % 10 == 0 && x != 0)) {
            return false;
        }

        int reserveNumber = 0;
        while (x > reserveNumber) {
            reserveNumber = reserveNumber * 10 + x % 10;
            x /= 10;
        }

        // 12321 的情况下会导致 @return reserveNumber 的值为123
        return x == reserveNumber || x == reserveNumber / 10;
    }
};


TEST(leetcode9, leetcode) {
    Solution solution;

    EXPECT_EQ(true, solution.isPalindrome(12321));
}



